/**
 * @(#)TaskManager.java        1.0 2/28/12
 * 
 * Copyright (c) 2012 public static droid main
 * Georgia Institute of Technology, Atlanta, GA
 * All rights reserved.
 */
package edu.gatech.oad.publicstaticdroidmain.taskmanager.model;

import java.util.Date;

/**
 * A facade that controls the entire TaskManager application.  This
 * class will be used by the UI to interact with the TaskManager,
 * ensuring that the UI is not exposed to any of the model's internal
 * objects and data.  Most of its methods are pass-through methods to 
 * UserAccount.
 * 
 * @version 1.0 2/28/12
 * @author Raheel Merali
 *
 */
public class TaskManager {
    
    private UserAccount account;
    /**
     * constructor, initializes the UserAccount
     * @param account UserAccount with the current user's information
     */
    public TaskManager(UserAccount account) {
	this.account = account;
    }
    
    /**
     * adds a Task to the account
     * 
     * @param taskToAdd the Task object to add
     * @param category category of the task
     */
    public void addTask(Task taskToAdd, String category) {
	account.addTask(taskToAdd, category);
    }
    
    
    /**
     * edits a task within the account
     * 
     * @param id task id
     * @param name task name
     * @param description task description
     * @param dueDate task due date
     * @param latitude task location longitude
     * @param longitude task location latitude
     * @param recurrence task's recurrence
     * @param category category of the task
     * @param completionStatus the new completion status
     * @return true if successful false if not
     */
    public boolean editTask(long id, String name, String description, 
	    Date dueDate, double latitude, double longitude, Task.Recurrence recurrence,
	    boolean completionStatus) {
	return account.editTask(id, name, description, dueDate, latitude, longitude, recurrence, 
		completionStatus);
    }
    
    /**
     * removes a task from the account
     * 
     * @param id the task ID
     * @return true if successful false if not
     */
    public boolean removeTask(long id) { 
	return account.removeTask(id);
    }
    
    /**
     * retrieves the Information about a task
     * 
     * @param id task ID
     * @param attributes attributes of the task
     * @return array of Task information
     */
    public String[] getTaskData(long id, Task.TaskAttribute[] attributes) { 
	return account.getTaskData(id, attributes);
    }

    /**
     * retrieves the categories existent in the account
     * 
     * @return array of category names
     */
    public String[] getCategories() { 
	return account.getCategories();
    }
    
    /**
     * adds a category to the account
     * 
     * @param categoryName the new category name
     * @return true if successful else false
     */
    public boolean addCategory(String categoryName) { 
	return account.addCategory(categoryName);
    }
    
    /**
     * changes the name of a category
     * 
     * @param oldName the old category name
     * @param newName the new category name
     * @return true if it changed else false
     */
    public boolean editCategoryName(String oldName, String newName) { 
	return account.editCategoryName(oldName, newName);
    }
    
    /**
     * removes a category from the account
     * 
     * @param categoryName category name to be removed
     * @return the name of the category that was removed
     */
    public String removeCategory(String categoryName) { 
	return account.removeCategory(categoryName);
    }

    /**
     * retrieves the full list of task data
     * 
     * @param attributes the attributes
     * @return 2d array of task data
     */
    public Object[] getMasterListDisplayData() {
    	return account.getMasterListDisplayData();
    }

    /**
     * retrieves only the data with specified attributes
     * 
     * @param attributes attributes of desired data
     * @return 2d array of task data
     */
    public String[][] getFilteredListDisplayData(Task.TaskAttribute[] attributes) {
	return account.getFilteredListDisplayData(attributes);
    }
    
    /**
     * Filters out the tasks not under the specified category
     * 
     * @param category name of desired category
     */
    public void filterByCategory(String category) { 
	account.filterByCategory(category);
    }
    
    /**
     * filters out any information not within the desired time period
     * 
     * @param start beginning of time period
     * @param end end of time period
     */
    public void filterByDueDate(Date start, Date end) { 
	account.filterByDueDate(start, end);
    }
    
    /**
     * filters out any tasks that don't have the specified recurrence
     * 
     * @param recurrence desired recurrence of the tasks
     */
    public void filterByRecurrence(Task.Recurrence recurrence) { 
	account.filterByRecurrence(recurrence);
    }
    
    /**
     * filters by location
     * 
     * @param startLatitude
     * @param endLatitude
     */
    public void filterByLatitude(double startLatitude, double endLatitude) { 
	account.filterByLatitude(startLatitude, endLatitude);
    }
    
    /**
     * filters by location
     * 
     * @param startLongitude
     * @param endLongitude
     */
    public void filterByLongitude(double startLongitude, double endLongitude) { 
	account.filterByLongitude(startLongitude, endLongitude);
    }
    
    /**
     * filters by completion status
     * 
     * @param completionStatus
     */
    public void filterByCompletionStatus(boolean completionStatus) {
	account.filterByCompletionStatus(completionStatus);
    }
    
    /**
     * searches for a task with a certain name
     * 
     * @param text the desired task's name
     */
    public void searchTaskNames(String text) { 
	account.searchTaskNames(text);
    }
    
    /**
     * searches for a task with a certain description
     * 
     * @param text the desired task's description
     */
    public void searchTaskDescriptions(String text) { 
	account.searchTaskDescriptions(text);
    }
    
    /**
     * resets the list of tasks within account to a full list of tasks 
     * 
     */
    public void resetFilteredList() { 
	account.resetFilteredList();
    }
    
    /**
     * getter for the account held
     * 
     * @return the account held
     */
    public UserAccount getAccount() {
    	return this.account;
    }

}